package com.tbit.main.service.impl;

import com.tbit.main.dao.core.AccountDao;
import com.tbit.main.dao.core.BatteryModelDao;
import com.tbit.main.pojo.BatteryModel;
import com.tbit.main.pojo.MachineBatteryModel;
import com.tbit.main.pojo.Result;
import com.tbit.main.service.BatteryModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service("batteryModelService")
public class BatteryModelServiceImpl implements BatteryModelService {
    @Autowired
    private BatteryModelDao batteryModelDao;
    @Resource
    private AccountDao accountDao;

    @Override
    public List<BatteryModel> getBatteryModel(Integer accountId) {
        return batteryModelDao.getBatteryModel(accountId);
    }

    @Override
    public BatteryModel getByModelId(Integer modelId) {
        return batteryModelDao.getByModelId(modelId);
    }

    @Override
    public List<MachineBatteryModel> getMachineBatteryModel(Integer accountId) {
        return batteryModelDao.getMachineBatteryModel(accountId);
    }

    @Override
    public MachineBatteryModel getMachineId(Integer machineId) {
        return batteryModelDao.getMachineId(machineId);
    }

    @Override
    public void batchAdd(List<Integer> machineIds, Integer batteryModelId) {
        batteryModelDao.batchAdd(machineIds, batteryModelId);
    }


    /**
     * 获取区域下所有的电池方案
     * @param accountId 区域id
     * @return Result<List<BatteryModel>>
     */
    @Override
    public Result<List<BatteryModel>> getAllBatteryModel(Integer accountId) {
        //同步管理端逻辑 查询系统-品牌-区域的电池方案
        List<Integer> accountIds = new ArrayList<>();
        accountIds.add(1);
        accountIds.add(accountDao.getByAccount(accountId));
        return Result.success(batteryModelDao.getAllBatteryModel(accountIds));
    }


}  